﻿using Mes.Domain.BoundedContext.Entities.Quality;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Quality
{
    public class SampleEntityConfig : IEntityTypeConfiguration<Sample>
    {
        public void Configure(EntityTypeBuilder<Sample> builder)
        {
            builder.ToTable("sample");
            builder.HasKey(b => b.Sample_Id);
            builder.Property(b => b.Ent_Id).IsRequired();
            builder.Property(b => b.Sample_Name);
            builder.Property(b => b.Item_Id);
            builder.Property(b => b.Wo_Id);
            builder.Property(b => b.Oper_Id);
            builder.Property(b => b.Seq_no);
            builder.Property(b => b.Context_Ent_Id);
            builder.Property(b => b.Context_Item_Id);
            builder.Property(b => b.Item_Category_Id);
            builder.Property(b => b.Process_Id);
            builder.Property(b => b.Context_Oper_Id);
            builder.Property(b => b.Freq_Id);
            builder.Property(b => b.Plan_id);
            builder.Property(b => b.Segment_Requirement_Id);
            builder.Property(b => b.Segment_Response_Id);
            builder.Property(b => b.Lot_No);
            builder.Property(b => b.Sublot_No);
            builder.Property(b => b.Requested_Time_Utc).IsRequired();
            builder.Property(b => b.Requested_Time_Local).IsRequired();
            builder.Property(b => b.Expiry_Time_Utc);
            builder.Property(b => b.Expiry_Time_Local);
            builder.Property(b => b.Warning_Time_Utc);
            builder.Property(b => b.Warning_Time_Local);
            builder.Property(b => b.Pulled_By);
            builder.Property(b => b.Pulled_Time_Utc);
            builder.Property(b => b.Pulled_Time_Local);
            builder.Property(b => b.Final).IsRequired();
            builder.Property(b => b.Finalized_By);
            builder.Property(b => b.Finalized_At_Utc);
            builder.Property(b => b.Finalized_At_Local);
            builder.Property(b => b.Verified_by);
            builder.Property(b => b.Sample_Status).IsRequired();
            builder.Property(b => b.Sample_Result);
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Priority);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Sample_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
